import { successResponse, errorResponseSchema } from './common.doc';

const userDataSchema = {
    type: 'object',
    properties: {
        username: {
            type: 'string',
            description: '用户名'
        },
        email: {
            type: 'string',
            description: '邮箱'
        },
        avatar: {
            type: 'string',
            description: '头像'
        },
        signature: {
            type: 'string',
            description: '个性签名'
        }
    }
};

export const userDocs = {
    get: {
        get: {
            summary: '获取用户信息',
            description: '获取用户信息',
            tags: ['用户'],
            responses: {
                200: successResponse(userDataSchema),
                500: errorResponseSchema
            }
        }
    },
    update: {
        put: {
            summary: '更新用户信息',
            description: '更新用户基本信息',
            tags: ['用户'],
            requestBody: {
                required: true,
                content: {
                    'application/json': {
                        schema: userDataSchema
                    }
                }
            },
            responses: {
                200: successResponse({}),
                500: errorResponseSchema
            }
        }
    },
    updatePassword: {
        put: {
            summary: '修改密码',
            description: '通过邮箱验证码修改密码',
            tags: ['用户'],
            requestBody: {
                required: true,
                content: {
                    'application/json': {
                        schema: {
                            type: 'object',
                            properties: {
                                email: {
                                    type: 'string',
                                    description: '邮箱'
                                },
                                password: {
                                    type: 'string',
                                    description: '新密码'
                                },
                                code: {
                                    type: 'number',
                                    description: '验证码'
                                },
                                type: {
                                    type: 'string',
                                    description: '验证码类型',
                                    enum: ['update_password']
                                }
                            }
                        }
                    }
                }
            },
            responses: {
                200: successResponse({}),
                500: errorResponseSchema
            }
        }
    }
}; 